import CryptoJS from 'crypto-js'

const _key = CryptoJS.enc.Utf8.parse('de7579adbb767122')

/**
 *
 */
const encrypt = (password) => {
  const _iv = CryptoJS.lib.WordArray.random(16)

  const _encrypted = CryptoJS.AES.encrypt(
    `${Date.now()}:${password}`,
    _key,
    {
      mode: CryptoJS.mode.CBC,
      padding: CryptoJS.pad.Pkcs7,
      iv: _iv
    }
  )

  return `${CryptoJS.enc.Hex.stringify(_iv)}:${_encrypted.toString()}`
}

export {
  encrypt
}
